﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Apollo.ElementUtils
{
    internal class Element
    {
        public static readonly Dictionary<ElementType, string> m_names = new()
        {
            [ElementType.ELEMENT_ERROR] = "error",
            [ElementType.ELEMENT_INTEGER] = "integer",
        };

        public ElementType Type { get; set; }
        public string Name
        {
            get
            {
                if (m_names.TryGetValue(Type, out var name))
                    return name;
                return "";
            }
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="elementType"></param>
        public Element(ElementType elementType = ElementType.ELEMENT_ERROR)
        {
            Type = elementType;  
        }

        /// <summary>
        /// 返回错误元素
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public static Element New_Error(string message)
        {
            return new ErrorElement(message);
        }

        /// <summary>
        /// 返回整数元素
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static Element New_Integer(int value)
        {
            return new IntegerElement(value);
        }
    }

     
    /// <summary>
    /// 目标类型
    /// </summary>
    public enum ElementType
    {
        ELEMENT_ERROR = 0,
        ELEMENT_INTEGER,
    }
}
